package com.tofindaway.test;

import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/*
 * 
 * 通过继承springTest，可以获取对事务的管理，一般的testcase 不能管理事务，需要手动处理。
 * 
 * */

//不知道什么用 run with.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:application-context.xml" })
public abstract class AbstractTestCase extends AbstractTransactionalJUnit4SpringContextTests {

	@Autowired
	private ApplicationContext applicationContext;

	@Autowired
	private SessionFactory sessionFactory;

	public ApplicationContext getApplicationContext() {
		return applicationContext;
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	@Before
	public void setUp() throws Exception {
		Assert.assertNotNull(applicationContext);
	}

	@After
	public void tearDown() throws Exception {

	}
}
